/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.bibliotecaDao;

import mx.its.dsw2.biblioteca.Modelo.Autor;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Yessy
 */
@Stateless
public class AutorDao extends AbstractDao<Autor> implements AutorDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8e-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public AutorDao() {
        super(Autor.class);
    }
   public boolean findDuplicity(Autor author){
   Query q=em.createNamedQuery("Autor.findDuplicity");
        q.setParameter("nombre", author.getNombre());
        q.setParameter("apellidoPaterno", author.getApellidoPaterno());
        q.setParameter("apellidoMaterno", author.getApellidoMaterno());
        return !q.getResultList().isEmpty();//si esta vacio mandara un no para decirque no hay duplicado y si ya lo hay dira que si
   } 
   
}
